﻿using System;
using System.Collections.Generic;
using ContractManager.Entity;
using Speed.Data;

namespace ContractManager.BLL.Business
{
    public static class ClsMemberBranch
    {
        public static List<MemberBranch> SelectAll()
        {
            using (var db = Sys.NewDb())
            {
                return Data.Base.MemberBranch.Select(db);
            }
            
        }

        public static void Insert(MemberBranch capital)
        {
            using (var db = Sys.NewDb())
            {
                db.Insert<MemberBranch>(capital, EnumSaveMode.Requery);
            }
           
        }

        public static void Update(MemberBranch capital)
        {
            using (var db = Sys.NewDb())
            {
                db.Update<MemberBranch>(capital);
            }
           
        }

        public static MemberBranch SelectByPk(Int32 mbId)
        {
            using (var db = Sys.NewDb())
            {
                return db.SelectSingle<MemberBranch>(string.Format("MbID={0}", mbId));
            }
            
        }

        public static MemberBranch SelectByCode(string mbCode)
        {
            using (var db = Sys.NewDb())
            {
                return db.SelectSingle<MemberBranch>(string.Format("MbCode='{0}'", mbCode));
            }
            
        }

        public static int DeleteByPk(Int32 mbId)
        {
            using (var db = Sys.NewDb())
            {
                return db.Delete<MemberBranch>(string.Format("MbID={0}", mbId));
            }
            
        }
    }
}
